package net.magicalcloud.magicalcloud.view.viewImpl.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import net.magicalcloud.magicalcloud.R;
import net.magicalcloud.magicalcloud.adapter.CloudFilesAdapter;
import net.magicalcloud.magicalcloud.adapter.VagueSearchFileAdapter;
import net.magicalcloud.magicalcloud.base.BaseActivity;
import net.magicalcloud.magicalcloud.entity.Files;
import net.magicalcloud.magicalcloud.presenter.VagueSearchPresenter;
import net.magicalcloud.magicalcloud.view.EmptyRecyclerView;
import net.magicalcloud.magicalcloud.view.IVagueSearchView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class VagueSearchActivity extends BaseActivity<IVagueSearchView,VagueSearchPresenter> implements IVagueSearchView{

    @BindView(R.id.searchListView)
    EmptyRecyclerView searchList;
    @BindView(R.id.et_vaguesearch)
    EditText etvalue;
    @BindView(R.id.tv_null)
    TextView tvnone;

    private CloudFilesAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vague_search);


        adapter=new CloudFilesAdapter();
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this);
        searchList.setLayoutManager(linearLayoutManager);
        searchList.setAdapter(adapter);
        searchList.setEmptyView(tvnone);

    }

    @OnClick(R.id.bt_ok)
    void vaguesearch(){

        mPresenter.vagueSearch(etvalue.getText().toString());


    }


    @Override
    protected VagueSearchPresenter createPresenter() {
        return new VagueSearchPresenter();
    }

    @Override
    public void setList(List<Files> filesList) {
        adapter.updateData(filesList);

    }
}
